Feature: User Sign In API

  # Author: Mariac
  # Execution&Update History
  # |Date       |Owner           |Update/Execution Remark         |Comments                          |
  # |03/24/2016 |Maria Chen      |First Draft                     |                                  |
  Background: 
    Given these Users:
      | email                   | password | alliancdId |
      | mariaghc@ehealth.com    | Qwer1234 | Gro21010   |
      | marialw@ehealth.com     | Qwer1234 | Lif25311   |
      | mariaretail@ehealth.com | Qwer1234 | null       |

  @happy 
  Scenario: Vaild email and password - GHC User sign in the system
    When I send a POST request with email "mariaghc@ehealth.com" and password "Qwer1234" to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      {"message":"success" }
      """

  @happy 
  Scenario: Vaild email and password - LWWA User sign in the system
     When I send a POST request with email "marialw@ehealth.com" and password "Qwer1234" to "/ehi/core/new-house-login?allid=Lif25311"
    Then the response status should be 200
    And the JSON response should be
      """
      { "message":"success" }
      """

  #################User belongs to other system can't login################
  @sad  
  Scenario: User Account belongs to Retail - User can't sign in the system
    When I send a POST request with email "mariaretail@ehealth.com" and password "Qwer1234" to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      { 
      "type": "UNAUTHORIZED",
      "message": "We're sorry, that username/password combination was not found in our system, please try again.",
      "errorType": "Login Error" 
      }
      """

  @sad 
  Scenario: User Account belongs to Lifewise - User can't sign in with GHC allianceId
    When I send a POST request with email "marialw@ehealth.com" and password "Qwer1234" to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      { 
      "type": "UNAUTHORIZED",
      "message": "We're sorry, that username/password combination was not found in our system, please try again.",
      "errorType": "Login Error" 
      }
      """

  #######################Email case insensitive, password case sensitive#####################
  @happy
  Scenario: Upper email and valid password - Check that email is case insensitive
    When I send a POST request with email "mariaGHC@ehealth.com" and password "Qwer1234" to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      { "message":"success" }
      """

  @sad 
  Scenario: Vaild email and Upper password - Check that password is case sensitive
   When I send a POST request with email "mariaghc@ehealth.com" and password "QWER1234" to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      { 
      "type": "UNAUTHORIZED",
      "message": "We're sorry, that username/password combination was not found in our system, please try again.",
      "errorType": "Login Error" 
      }
      """

###################Parameters empty/invalid######################   
      @sad  
  Scenario: AllianceId Invalid - User can't sign in the system
   When I send a POST request with email "mariaghc@ehealth.com" and password "Qwer1234" to "/ehi/core/new-house-login?allid=Gro32332"
    Then the response status should be 500
      
@sad 
  Scenario: Email empty - User can't sign in the system
    When I send a POST request with email " " and password "Qwer1234" to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      { 
      "type": "UNAUTHORIZED",
      "message": "Please enter a valid email address",
      "errorType": "Login Error" 
      }
      """

  @sad 
  Scenario: Password empty - User can't sign in the system
    When I send a POST request with email "mariaghc@ehealth.com" and password " " to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      { 
      "type": "UNAUTHORIZED",
      "message": "We're sorry, that username/password combination was not found in our system, please try again.",
      "errorType": "Login Error" 
      }
      """

  @sad 
  Scenario: Email invalid - User can't sign in the system
    When I send a POST request with email "mariaghc11@ehealth.com" and password "Qwer1234" to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      { 
      "type": "UNAUTHORIZED",
      "message": "We're sorry, that username/password combination was not found in our system, please try again.",
      "errorType": "Login Error" 
      }
      """

  @sad 
  Scenario: Password invalid - User can't sign in the system
    When I send a POST request with email "mariaghc@ehealth.com" and password "Qwer123456" to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      { 
      "type": "UNAUTHORIZED",
      "message": "We're sorry, that username/password combination was not found in our system, please try again.",
      "errorType": "Login Error" 
      }
      """

  @sad 
  Scenario: Email/Password invalid - User can't sign in the system
    When I send a POST request with email "mariaghc11@ehealth.com" and password "Qwer1234567" to "/ehi/core/new-house-login?allid=Gro21010"
    Then the response status should be 200
    And the JSON response should be
      """
      { 
      "type": "UNAUTHORIZED",
      "message": "We're sorry, that username/password combination was not found in our system, please try again.",
      "errorType": "Login Error" 
      }
      """
